package com.dingwen.treasure.open.api.sms.aliyun.config;

import com.aliyun.teaopenapi.models.Config;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云短信配置： //TODO 配置项优化
 *
 * @author dingwen
 * @date 2022/12/09
 */
@Configuration(proxyBeanMethods = false)
@ConfigurationProperties(prefix = "treasure.sms.aliyun")
@RefreshScope
@Getter
@Setter
@Slf4j
public class AliyunSmsConfig {

    /**
     * accessKeyId
     */
    private String accessKeyId = "LTAI5tAMAaX3iGfhuUiDMoit";


    /**
     * accessKeySecret
     */
    private String accessKeySecret = "SpUUVjgUZ49ccTXJWHyW90vkG2j81l";


    /**
     * 短信签名-应用
     */
    private String signNameTreasure = "丁文Treasure项目";


    /**
     * 短信模版code-欢迎模版
     */
    private String templateCodeWelcome = "SMS_263895079";


    @Bean
    public com.aliyun.dysmsapi20170525.Client aliSmsClient() {
        Config config = new Config();
        config.accessKeyId = accessKeyId;
        config.accessKeySecret = accessKeySecret;
        try {
            return new com.aliyun.dysmsapi20170525.Client(config);
        } catch (Exception e) {
            log.error("阿里云短信客户端初始化成功");
            return null;
        }
    }
}
